<template>
  <el-dialog :title="title"
             :visible.sync="visible"
             v-loading="loading"
             :before-close="modalClose"
             :close-on-click-modal="false"
             :close-on-press-escape="false"
             width="40%">
    <div class="detailView">
      <div class="detail">
        <div class="name">创建时间</div>
        <div class="value">2021-11-08 13:53:34</div>
      </div>
      <div class="detail">
        <div class="name">所属公司</div>
        <div class="value">2021-11-08 13:53:34</div>
      </div>
      <div class="detail">
        <div class="name">联系电话</div>
        <div class="value">2021-11-08 13:53:34</div>
      </div>
      <div class="detail">
        <div class="name">地址</div>
        <div class="value">2021-11-08 13:53:34</div>
      </div>
    </div>
    <el-card class="mt-20">
      <div slot="header">权益清单</div>
      <el-table strip
                border
                :data="tableData"
                style="width: 100%">
        <el-table-column prop="name"
                         label="试纸名称">
        </el-table-column>
        <el-table-column prop="name"
                         label="数量">
        </el-table-column>
      </el-table>
    </el-card>
    <el-form ref="formRef"
             :model="formModel"
             :rules="formRules"
             label-width="140px"
             class="mt-20">
      <el-form-item label="物流公司："
                    prop="company">
        <el-input v-model="formModel.company"
                  placeholder="请输入物流公司"
                  class="w-200"></el-input>
      </el-form-item>

      <el-form-item label="物流编号："
                    prop="sn">
        <el-input v-model="formModel.sn"
                  placeholder="请输入物流编号"
                  class="w-200"></el-input>
      </el-form-item>
      <el-form-item label="发货人："
                    prop="sendUser">
        <el-input v-model="formModel.sendUser"
                  placeholder="请输入发货人"
                  class="w-200"></el-input>
      </el-form-item>
      <el-form-item label="发货时间："
                    prop="sendTime">
        <el-date-picker v-model="formModel.sendTime"
                        type="datetime"
                        placeholder="请选择发货时间">
        </el-date-picker>
      </el-form-item>
    </el-form>
    <p align="center">
      <el-button @click="modalClose"
                 type="primary">取 消</el-button>
      <el-button @click="submitForm"
                 type="primary">发 货</el-button>
    </p>
  </el-dialog>

</template>
<script>
  export default {
    props: {
      dataObj: {
        type: Object,
        default: {}
      },
      visible: {
        type: Boolean,
        default: false
      },
    },
    name: 'buyMedicineDialog', // 购药回访权益配置
    data () {
      return {
        title: '发货',
        loading: false,
        formModel: {
          id: null,
          company: '', // 物流公司
          sn: '', // 物流编号
          sendUser: '', // 发货人
          sendTime: '', // 发货时间
        },
        tableData: [],
        formRules: {
          company: [{ required: true, message: '请输入物流公司', trigger: 'blur' }],
          sn: [{ required: true, message: '请输入物流编号', trigger: 'blur' }],
          sendUser: [{ required: true, message: '请输入发货人', trigger: 'blur' }],
          sendTime: [{ required: true, message: '请选择发货时间', trigger: 'change' }]
        },

      }
    },
    methods: {
      modalClose () {
        this.$emit('update:visible', false); // 直接修改父组件的属性
      },

      // 提交
      submitForm () {
        this.$refs['formRef'].validate((valid) => {
          if (valid) {
            console.log(this.formModel);
            return
            this.post(this.api.company.updateReadDoctorConfig, this.formModel).then(res => {
              if (res.data.code === '200') {
                this.$message.success('保存成功!');
                this.$parent.getList();
                this.modalClose();
              }
            })
          }
        })
      },
      getDetail () {
        this.post(this.api.company.getReadDoctorConfigDetail, {
          id: this.dataObj.id
        }).then(res => {
          if (res.data.code === '200') {
            let resData = res.data.object;
            this.formModel.id = resData.id;
          }
        })
      }
    },
    created () {
      if (this.dataObj) {
        this.getDetail();
        this.title = '查看详情';
      }
    },
  }
</script>
<style lang="scss" scoped>
</style>